/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2021-11-25 14:54:33
 * 天凉好个秋
 */

// 将对象中所有可转为number型的字符串转为number
export const objToInt = (params: object) => {
  if (typeof params !== "object") return params;
  for (let [key, value] of Object.entries(params)) {
    if (!isNaN(value)) params[key] = Number(value);
  }
  return params;
};

/**
 * @description: 生成随机字符串
 * @param {number} len 结果长度
 * @return {string} 
 */
export const randomStr = (len: number = 10): string => {
  const str = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
  const max = str.length;
  let res = "";
  for (let i = 0; i < len; i++) {
    res += str.charAt(Math.floor(Math.random() * max));
  }
  return res
}
